:root {
    --bg-color: #f5f5f5;
    --text-color: #333;
    --header-color: #2c3e50;
    --card-bg: #fff;
    --card-shadow: rgba(0, 0, 0, 0.1);
    --border-color: #ddd;
    --primary-color: #3498db;
    --primary-hover: #2980b9;
    --success-color: #2ecc71;
    --success-hover: #27ae60;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --footer-color: #7f8c8d;
    --header-bg: #f8f9fa;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --header-color: #e0e0e0;
    --card-bg: #1e1e1e;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --border-color: #444;
    --primary-color: #2196f3;
    --primary-hover: #1976d2;
    --success-color: #4caf50;
    --success-hover: #388e3c;
    --danger-color: #f44336;
    --danger-hover: #d32f2f;
    --footer-color: #9e9e9e;
    --header-bg: #1a1a1a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    color: var(--header-color);
    font-size: 2rem;
}

.converter {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--card-shadow);
    padding: 20px;
    margin-bottom: 20px;
    flex-grow: 1;
}

.input-area, .output-area {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--header-color);
}

textarea {
    width: 100%;
    height: 150px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
    font-size: 16px;
    background-color: var(--card-bg);
    color: var(--text-color);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: var(--primary-hover);
}

#clearText {
    background-color: var(--danger-color);
}

#clearText:hover {
    background-color: var(--danger-hover);
}

#copyText {
    background-color: var(--success-color);
}

#copyText:hover {
    background-color: var(--success-hover);
}

.theme-toggle {
    background-color: #8e44ad;
}

.theme-toggle:hover {
    background-color: #7d3c98;
}

.message {
    margin: 10px 0;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message.show {
    opacity: 1;
}

.message.success {
    background-color: rgba(46, 204, 113, 0.2);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.message.error {
    background-color: rgba(231, 76, 60, 0.2);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

footer {
    text-align: center;
    margin-top: auto;
    padding: 10px 0;
    color: var(--footer-color);
    font-size: 14px;
}

/* 响应式布局 */
/* 平板 */
@media screen and (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .converter {
        padding: 15px;
    }
    
    textarea {
        height: 120px;
    }
    
    button {
        padding: 8px 16px;
        font-size: 14px;
    }
}

/* 手机 */
@media screen and (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .converter {
        padding: 12px;
        margin-bottom: 10px;
    }
    
    textarea {
        height: 100px;
        font-size: 15px;
    }
    
    .controls {
        padding: 10px 0;
        flex-direction: row;
        flex-wrap: nowrap;
    }
    
    button {
        width: 100%;
        padding: 12px 0;
        font-size: 16px;
    }
}

/* 手机竖屏 */
@media screen and (max-width: 480px) and (max-aspect-ratio: 13/9) {
    html, body {
        min-height: 100%;
    }
    
    .container {
        max-width: 100%;
        height: 100vh;
        padding: 0;
        margin: 0;
    }
    
    header {
        padding: 15px 0;
        margin-bottom: 0;
        background-color: var(--header-bg);
    }
    
    .converter {
        border-radius: 0;
        box-shadow: none;
        margin: 0;
        flex-grow: 1;
        display: flex;
        flex-direction: column;
    }
    
    .input-area, .output-area {
        flex-grow: 1;
        margin-bottom: 10px;
        display: flex;
        flex-direction: column;
    }
    
    textarea {
        flex-grow: 1;
        height: auto;
        min-height: 25vh;
    }
    
    .controls {
        padding: 10px 0;
    }
    
    footer {
        padding: 10px;
        background-color: #1e1e1e;
    }
}

/* 手机横屏 */
@media screen and (max-width: 896px) and (min-aspect-ratio: 13/9) {
    .container {
        padding: 5px;
    }
    
    header {
        margin-bottom: 5px;
    }
    
    header h1 {
        font-size: 1.2rem;
    }
    
    .converter {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr;
        grid-gap: 10px;
        padding: 10px;
    }
    
    .controls {
        grid-column: 1 / -1;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
    }
    
    button {
        flex: 1;
        max-width: 24%;
        font-size: 14px;
        padding: 8px 0;
    }
    
    .input-area, .output-area {
        display: flex;
        flex-direction: column;
        margin-bottom: 0;
    }
    
    textarea {
        height: 100%;
        min-height: 120px;
    }
}

/* ----弹窗---- */
/* 显示：modal-overlay的style.display设为"flex"
   关闭：none */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* 弹窗容器 */
.modal {
    background: var(--card-bg);
    color: var(--text-color);
    border-radius: 16px;
    padding: 24px;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transform: scale(0.5);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                opacity 0.3s ease-out;
    will-change: transform, opacity;
}

/* 弹窗显示时的状态 */
.modal-overlay[style*="display: flex"] .modal {
    transform: scale(1);
    opacity: 1;
}

/* 关闭动画 */
.modal-overlay.closing .modal {
    transform: scale(0.3);
    opacity: 0;
    transition: transform 0.3s ease-in, 
                opacity 0.2s ease-in;
}

.modal-content {
    text-align: center;
}

.modal-content p {
    margin: 0 0 20px 0;
    line-height: 1.5;
    font-size: 16px;
}

/* 确定按钮样式 */
.modal-button {
    background: #2196f3;
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.modal-button:hover {
    background: #1976d2;
}

[data-theme="dark"] .modal {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* 响应式设计 */
@media (max-width: 480px) {
    .modal {
        width: 85%;
        padding: 20px;
    }
    
    .modal-content p {
        font-size: 14px;
    }
    
    .modal-button {
        padding: 8px 24px;
        font-size: 14px;
    }
}